package com.example.log.alarm.advice.exeception;

import com.example.log.alarm.constant.ThrowableConstant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.ToString;
import org.slf4j.MDC;

import java.time.LocalDateTime;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @program: spring-agent
 * @description:
 * @author: zt22328 赵儒定
 * @create: 2023-05-05 10:54
 **/
@Data
@ToString
public class ThrowableInfo {

    /**
     * md5key(clazz+:+message+:+stackTrace)
     */
    private String throwableId;

    private String clazz;

    private String message;

    /**
     * md5key(stackTrace)
     */
    private String stackTraceId;

    private String stackTrace;

    private List<ThrowableDesc> throwableDescList = new CopyOnWriteArrayList<>();

    public ThrowableInfo() {
    }

    public void addThrowableDesc(String threadName, LocalDateTime triggerTime) {
        throwableDescList.add(new ThrowableDesc(threadName, triggerTime));
    }

    @Data
    @AllArgsConstructor
    public static class ThrowableDesc {

        private String threadName;

        private LocalDateTime triggerTime;

    }
}
